﻿using System;
using System.Reflection;

namespace GitManageFileVersionAvaloniaApp.Utils
{
    public static class ObjectExtensions
    {
        public static object GetValueByPropertyName(this object o, string propertyName)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException("propertyName");
            }
            PropertyInfo info = o.GetType().GetProperty(propertyName);
            if (info != null)
            {
              return info.GetValue(o);
            }
            return default;
        }
    }
}
